// pages/orderreceipt/orderreceipt.js
const app=getApp()
Page({
  

  /**
   * 页面的初始数据
   */
  data: {
    imgurl:app.globalData.Imageurl,
    isshow:false,
    signedin:false,
    isloadcomplete:true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getGoodsOrderDetails(options.orderId)
    this.setData({
      id:options.orderId
    })

  },
  godetails(e){
    console.log(e)
    wx.navigateTo({
      url: '/pages/details/details?goodsid='+e.currentTarget.dataset.goodsid,
    })
  },
  //联系客服
  handleContact (e) {
    console.log(e.detail.path)
    console.log(e.detail.query)
  },
  getGoodsOrderDetails(id){
    var t=this
    wx.request({
      url: app.globalData.Interfaceurl + 'getGoodsOrderDetails',
      method: "post",
      header: {
          "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
          userId: app.globalData.userId,
          orderId:id
          // userId:"1517311605850923008",
          // orderId:"1517342786680942592",
      },
      success: res => {
          console.log(res)
          t.setData({
            goods:res.data.goodsOrder,
            consigneeAddress:res.data.goodsOrder.consigneeAddress,
            consigneeMobile:res.data.goodsOrder.consigneeMobile,
            consigneeName:res.data.goodsOrder.consigneeName,
            isloadcomplete:false
          })
          console.log(t.data.goods)
          // if (myorderStats==''&&mypayStats=='') {
            
    
          // }
          
          
          
      }
  })
  },
  wuliu(){
    this.getGoodsOrderLogistics(this.data.id)
    this.setData({
      isshow:true
    })
  },
  offwl(){
    this.setData({
      isshow:false
    })
  },
  getGoodsOrderLogistics(id){
    var t=this
    wx.request({
      url: app.globalData.Interfaceurl + 'getGoodsOrderLogistics',
      method: "post",
      header: {
          "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
          userId:app.globalData.userId,
          orderId:id
          // userId:"1517311605850923008",
          // orderId:"1517342786680942592",
      },
      success: res => {
          console.log(res)
          if(res.data.result==0){
          this.setData({
            logistics:res.data.logistics
            
          })

          if(res.data.logistics.issign.indexOf('已签收')>=0){
            t.setData({
              signedin:true
            })
          }
         
        }
      }
  })
  },
  // 去退款
  goaftersale(e){
    wx.navigateTo({
      url: '/pages/aftersale/aftersale?orderId='+e.currentTarget.dataset.id,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {

  // }
})